﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<CRM.Database.Model.profineRegions>>" %>
<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<CRM.Models.profineRegions>>" %>--%>
<%@ Import Namespace="CRM.Models" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdprofineRegions";
                                        settings.KeyFieldName = "IdProfineRegion";
                                        settings.CallbackRouteValues = new { Controller = "Dictionaries", Action = "profineRegionsPartiotional" };
                                        settings.SettingsPager.PageSize = 15;

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProfineRegionNameInRussian;
                                            column.FieldName = "NameRu";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.ProfineRegionNameInEnglish;
                                            column.FieldName = "NameEn";
                                        });
                                        
                                        settings.Columns.Add(column =>
                                        {
                                            column.FieldName = "IdCountry";
                                            column.Caption = Resourses.Country;
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;
                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var countriesCol = new CRM.Database.Model.CountriesCollection();
                                                comboBoxProperties.DataSource = countriesCol.CountriesList;
                                                //comboBoxProperties.DataSource = DB.Countries;
                                                comboBoxProperties.TextField = "CountryNameLocalized";
                                                comboBoxProperties.ValueField = "IdCountry";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsActive;
                                            column.FieldName = "IsActive";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });
                                        
                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                        settings.CommandColumn.DeleteButton.Visible = false;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = true;
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Dictionaries", Action = "profineRegionsPartialUpdate" };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Dictionaries", Action = "profineRegionsPartialAdd" };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Dictionaries", Action = "profineRegionsPartialDelete" };
                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                        settings.Width = Unit.Percentage(100);
                                    })
       .Bind(Model).GetHtml();
%>